import ObservableObject from "../observer/observable.object"
import * as THREE from "three"
import n from "../math/63560"
import l from "../math/69626"
import Matrix from "../three/Matrix"
export default class CameraPoseData extends ObservableObject {
  position: THREE.Vector3
  rotation: THREE.Quaternion
  focalDistance: number
  projection: Matrix
  constructor(e: number) {
    super()
    this.position = new THREE.Vector3()
    this.rotation = new THREE.Quaternion()
    this.focalDistance = -1
    this.projection = n.AN(e)
  }
  aspect() {
    return this.projection.elements[5] / this.projection.elements[0]
  }
  clone(e = new CameraPoseData(this.aspect())) {
    e.position.copy(this.position)
    e.rotation.copy(this.rotation)
    e.focalDistance = this.focalDistance
    e.projection.copy(this.projection)
    e.commit()
    return e
  }
  isOrtho() {
    return l.Pp(this.projection)
  }
  fovX() {
    return 2 * Math.atan((1 * this.aspect()) / this.projection.elements[5])
  }
  fovY() {
    return 2 * Math.atan(1 / this.projection.elements[5])
  }
}
